#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<string.h>
int main()
{
    int n = 0;
    int j = 0;
    scanf("%d", &n);
    getchar();
    for (j = 0; j < n; j++)
    {
        char pd[100] = { 0 };
        scanf("%s", pd);
        int f1 = 1, f2 = 1, f3 = 1, f4 = 1;
        int fb = 0, fs = 0, fn = 0;
        int i = 0;
        for (i = 0; i < strlen(pd); i++)
        {
            if ((pd[i] >= 'a' && pd[i] <= 'z') || (pd[i] >= 'A' && pd[i] <= 'Z') || (pd[i] >= '0' && pd[i] <= '9'))
            {
                ;
            }
            else
            {
                f1 = 0;
                break;
            }
        }
        if (pd[0] >= '0' && pd[0] <= '9')
        {
            f2 = 0;
        }
        if (strlen(pd) < 8)
        {
            f3 = 0;
        }
        for (i = 0; i < strlen(pd); i++)
        {
            if (pd[i] >= 'a' && pd[i] <= 'z' && fs == 0)
            {
                fs++;
            }
            if (pd[i] >= 'A' && pd[i] <= 'Z' && fb == 0)
            {
                fb++;
            }
            if (pd[i] >= '0' && pd[i] <= '9' && fn == 0)
            {
                fn++;
            }
        }
        if (fs + fb + fn < 2)
        {
            f4 = 0;
        }
        if (f1 + f2 + f3 + f4 == 4)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}